LeakyReLu
Leaky ReLU激活函数。
该激活函数定义如下:
\[\begin{split}leaky\_relu(x) =
\begin{cases}
x, & \text{if } x \geq 0; \\
\alpha \cdot x, & \text{otherwise.}
\end{cases}\end{split}\]
其中, \(\alpha\) 表示 alpha 参数。
- 输入:
input - 输入数据的地址。
elem_cnt - 计算长度。
alpha - 公式中的alpha参数。
core_mask - 核掩码。
- 输出:
output - 输出地址。
- 支持平台:
FT78NEMT7004
备注
FT78NE 支持int8, fp32
MT7004 支持fp16, fp32
共享存储版本:
-
void fp_leaky_relu_s(float *input, float *output, int elem_cnt, float alpha, int core_mask)
-
void hp_leaky_relu_s(half *input, half *output, int elem_cnt, half alpha, int core_mask)
-
void i8_leaky_relu_s(const int8_t *input, int8_t *output, int elem_cnt, float alpha, int core_mask)
C调用示例:
1void main() {
2 float* input = (float*)0x82000000;
3 float* output = (float*)0x88000000;
4 int length = 1000;
5 float alpha = 0.9;
6 int core_mask = 0b1111;
7 fp_leaky_relu_s(input, output, length, alpha, core_mask);
8}
私有存储版本:
-
void fp_leaky_relu_p(float *input, float *output, int elem_cnt, float alpha, int core_mask)
-
void hp_leaky_relu_p(half *input, half *output, int elem_cnt, half alpha, int core_mask)
-
void i8_leaky_relu_p(const int8_t *input, int8_t *output, int elem_cnt, float alpha, int core_mask)
C调用示例:
1void main() {
2 float* input = (float*)0x10000000; // 私有存储版本地址设置在AM内
3 float* output = (float*)0x10010000;
4 int length = 1000;
5 float alpha = 0.9;
6 int core_mask = 0b0001; // 私有存储版本只能设置为一个核心启动
7 fp_leaky_relu_p(input, output, length, alpha, core_mask);
8}